package IO操作;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class PWDemo3 {
    public static void main(String[] args) throws IOException {

        FileOutputStream fos =new FileOutputStream("note.txt");
        OutputStreamWriter osw =new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        BufferedWriter bw =new BufferedWriter(osw);
        PrintWriter pw =new PrintWriter(bw,true);//添加true可以在输入的时候自动刷新文本，实时看到内容

        Scanner scan =new Scanner(System.in);
        String name;
       // equalsIgnoreCase判断时可以忽略大小写
        //!("exit".equalsIgnoreCase(name= scan.nextLine()))
        while (!("exit".equals(name= scan.nextLine()))){
            pw.println(name);//如果此时用print的方法或者write方法，即便PrintWrite有true参数也无法自动刷新
        }
        pw.close();
    }
}
